<?php
	$css_list[0]['url'] = './tpl/css/mailrss.css';
	$js_list[0][] = './public/js/jquery.slides.js';
?>
<!--{template inc/header}-->
<div id="body" class="wrapper">

    <div id="content_body_wrap" class="fl mt20">

                <div class="piece" >
			<div class="piece_hd" > <b class="hl"></b> <b class="hr"></b> </div>
                            <div class="piece_bd">
                                <h2 class="rss_cate_title" ><a href="{u mailrss/show id=$cate_item['cate_id']}" >最新订阅</a></h2>
				<ul class="rss_cate_list clear_in" >
                                    <!--{loop $rss_cates['list'] $cate_item}--> 
					<li>
                                                <a class="fl cate_img" href="{u mailrss/show id=$cate_item['cate_id']}" target="_blank"><img class="r5" height="80" src="{$cate_item['cate_icon']}" /></a>
                                                <h3 class="cr_t"><a class="glink" href="{u mailrss/show id=$cate_item['cate_id']}" target="_blank">{$cate_item['cate_name']}</a></h3>
                                                <p class="cr_i" ><span><b>{$cate_item['rss_count']}</b>成员订阅</span>  </p>
                                                <!--{if $cate_item['is_rss'] == 1 }-->
                                                    <p class="cr_d" >已订阅，<a  href="javascript:;" onclick="RemoveRss({$cate_item['cate_id']},this);">取消订阅</a></p>
                                                <!--{else}-->
                                                    <p class="cr_d" ><a class="rss_a" href="javascript:;" onclick ="AddRss({$cate_item['cate_id']},this);">订阅</a></p>
                                                <!--{/if}--> 
                                        </li>
                                    <!--{/loop}-->
				</ul>
			</div>
                 
			<div class="piece_ft" > <b class="fl"></b> <b class="fr"></b> </div>
		</div>
        </div>

        <div id="right_side" class="fr mt20">
        <div class="piece piece_ws" >
			<div class="piece_hd" > <b class="hl"></b> <b class="hr"></b> </div>
			<div class="piece_bd">
				<h3>订阅快报</h3>
                                <!--{if $rss_user_list}-->
				<ul class="rss_user_list">
                                    <!--{loop $rss_user_list['list'] $rss_user_item}-->
					<li>
						<p><a class="tlink" target="_blank" href="{u u/index uid=$rss_user_item['uid']}">{$rss_user_item['user_name']}</a>订阅了</p>
						<p class="gl_gt" ><a class="glink" target="_blank" href="{u mailrss/show id=$rss_user_item['cate_id']}">{$rss_user_item['short_name']}</a></p>
					</li>
                                       <!--{/loop}-->
				</ul>
                                <!--{/if}-->
			</div>
			<div class="piece_ft" > <b class="fl"></b> <b class="fr"></b> </div>
		</div>
            </div>
</div>
<!--{template inc/footer}-->
<script>
function AddRss(cate_id,obj){
        var query = new Object();
        query.cate_id = cate_id;
        if(USER_ID == 0){
            alert('请先登录，再进行订阅操作！');
        }
        $.ajax({    
                    url: SITE_PATH+"mailrss.php?action=ajax_rss",
                    type: "POST",
                    data:query,
                    cache:false,
                    dataType:'json',
                    success:function(result){
                            if(result.status == 0){
                                alert('订阅失败,请稍候再试！');
                            }
                            else
                            {   
                                var rss_count = parseInt($(obj).parent().parent().find("b").html());
                                $(obj).parent().parent().find("b").html(rss_count+1);
                                var html_str = '已订阅，<a href="javascript:;" onclick="RemoveRss('+query.cate_id+',this);">取消订阅</a>';
                                $(obj).parent().html(html_str);
                            }
                    },
                    error:function(){
                            
                    }
                });
 }
function RemoveRss(cate_id,obj){
        var query = new Object();
        query.cate_id = cate_id;
        $.ajax({    
                    url: SITE_PATH+"mailrss.php?action=ajax_remove_rss",
                    type: "POST",
                    data:query,
                    cache:false,
                    dataType:'json',
                    success:function(result){
                            if(result.status == 0){
                                alert('取消订阅失败,请稍候再试！');
                            }
                            else
                            {
                                var rss_count = parseInt($(obj).parent().parent().find("b").html());
                                $(obj).parent().parent().find("b").html(rss_count-1);
                                var html_str = '<a class="rss_a" href="javascript:;" onclick ="AddRss('+cate_id+',this);">订阅</a>';
                                $(obj).parent().html(html_str);
                            }
                    },
                    error:function(){
                            
                    }
                });
}
</script>